package com.grapes.business;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.grapes.model.Major;

public class CareerPreferenceBusiness {
	private static CareerPreferenceBusiness instance;

	private CareerPreferenceBusiness() {
	};

	public static CareerPreferenceBusiness getInstance() {
		if (null == instance) {
			instance = new CareerPreferenceBusiness();
		}
		return instance;
	}

	// TODO
	public List<Major> getAllMajors() {
        
		return getFakeMajors();
	}

	public List<Major> getFakeMajors() {
		List<Major> majors = new LinkedList<Major>();
        int TOTAL_MAJORS=36;
        int MAJOR_COUNT_EACH_TYPE=12;
		for (int index = 0; index < TOTAL_MAJORS; index++) {
			Major major = new Major();
			if(index<MAJOR_COUNT_EACH_TYPE)
			   major.setCategory(Major.MAJOR_CATEGORY_ART);
			else if(index<MAJOR_COUNT_EACH_TYPE*2)
				major.setCategory(Major.MAJOR_CATEGORY_SCIENSE);
			else 
				major.setCategory(Major.MAJOR_CATEGORY_ENGINEERING);
			major.setMajorId(String.valueOf(index));
			major.setMajorName("Major"+String.valueOf(index));
			majors.add(major);
		}
		return majors;
	}
	
    public void submitPersonMajor(String renrenId,String majorid)
    {
		Map<String, String> params = new HashMap<String, String>();
		params.put("renrenId", renrenId);
		params.put("majorid", majorid);
		Connection.getInstance().executeHttpPost(
				Connection.BIZ_SUBMIT_RERSONAL_MAJOR, params);
    }
}
